package cn.edu.scau.cmi.wujiaxian.exercise11;

import java.awt.Color;
import java.awt.GridLayout;
import java.awt.Label;

import javax.swing.JPanel;

public class GridLayoutPanel extends JPanel{
	private static final long serialVersionUID = 4174621914605686809L;

	public GridLayoutPanel() {
		GridLayout gridLayout = new GridLayout(12, 12); //网格布局
		setLayout(gridLayout);
		Label[][] label = new Label[12][12];
		for (int i = 0; i < 12; i++) {
			for (int j = 0; j < 12; j++) {
				label[i][j] = new Label();
				if ((i + j) % 2 == 0) {
					label[i][j].setBackground(Color.BLACK);
				} else {
					label[i][j].setBackground(Color.WHITE);
				}
				add(label[i][j]);
			}
		}
	}
	
}
